<?php

declare(strict_types=1);

namespace App\Services\Users;

use App\Utils\Services\BaseServices;
use App\Model\Users\User as UserModel;

/**
 * Class User
 * @author zx
 * @package App\Services\Users
 */
Class User extends BaseServices
{
    public function model():string
    {
        return UserModel::class;
    }

    /**
     * 注册
     * @param array $params
     * @return \App\Model\Model|\Hyperf\Database\Model\Model|mixed
     */
    public function register(array $params)
    {
        $model = $this->where('mobile', $params['mobile'])->first();
        if (!$model) {
            $params['nickname'] = 'user_'.mt_rand(100000, 999999);
            $model = $this->create($params);
        }

        return $model;
    }
}
